# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=php-findsock-shell
pkgver=2.b8a984f
pkgrel=1
pkgdesc='A Findsock Shell implementation in PHP + C.'
groups=('blackarch' 'blackarch-webapp' 'blackarch-backdoor')
arch=('x86_64' 'aarch64')
url='https://github.com/pentestmonkey/php-findsock-shell'
license=('GPL2')
depends=('php')
makedepends=('git')
source=("git+https://github.com/pentestmonkey/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  # lame code, lame tool ...
  gcc -o findsock findsock.c
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE COPYING*

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec php $pkgname.php "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

